# 题目：给定一个整数数组，找到一个具有最大和的连续子数组

def max_sum(nums):
    max_current = max_global = nums[0]
    for num in nums[1:]:
        max_current = max(num,max_current+num)
        max_global = max(max_current,max_global)
    return max_global

print(max_sum([-2,1,-3,4,-1,2,1,-5,4]))